package bebetter.demo.common.model;

import bebetter.basejpa.enums.EnumSysRoleBase;
import bebetter.basejpa.enums.ISysRole;
import bebetter.basejpa.model.base.Id_CreateTime;
import bebetter.demo.common.enums.EnumSex;
import bebetter.generate.annotation.GColumn;
import bebetter.generate.annotation.GEntity;
import com.google.gson.annotations.Expose;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Type;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import java.util.Date;
import java.util.List;

@EqualsAndHashCode(callSuper = true)
@GEntity(value = "用户", userHideColumns = {"createTime"})
@Entity
@Data
public class User extends Id_CreateTime {
    @GColumn("用户名")
    String username;
    @Expose(serialize = false)
    @GColumn("密码")
    transient String password;//JsonIgnore只在输出到页面json时被隐藏//transient
    @GColumn(value = "是否可用")
    Boolean enabled;//是否可登录   ,true=1=可以,false=0=不可
    @GColumn(value = "性别")
    @Enumerated(EnumType.STRING)
    EnumSex sex;
    @Type(type = "json")
    List<String> roles;
    @GColumn("最后登录时间")
    Date lastLoginTime;//最后登录时间

    public ISysRole getSysRole() {
        return EnumSysRoleBase.用户;
    }
}
